package cn.tedu.boot24.controller;

import cn.tedu.boot24.entity.Hero;
import cn.tedu.boot24.mapper.HeroMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class HeroController {
    @Autowired
    HeroMapper mapper;
    @RequestMapping("/insert")
    @ResponseBody
    public String insert(Hero hero){
        System.out.println("hero = " + hero);
        mapper.insert(hero);
        return "添加成功！";
    }

    @RequestMapping("/delete")
    @ResponseBody
    public String delete(String name){
        mapper.delete(name);
        return "删除成功！";
    }

    @RequestMapping("/update")
    @ResponseBody
    public String update(Hero hero){
        mapper.update(hero);
        return "修改成功！";
    }

    @RequestMapping("select")
    @ResponseBody
    public String select(int id){
        List<Hero> list =mapper.select();
        String html="<table border=1>";

        html+="</table>";
        return "查询成功！";
    }
}
